﻿using Inovout.People.Memberships.Models;
using Inovout.Repositories;
using NHibernate.Criterion;

namespace Inovout.People.Memberships.Repositories
{
    public class PersonMembershipRepository : DataObjectRepository<PersonMembership>
    {

        public PersonMembership FindByUserName(string userName)
        {
            var list = base.OpenSession().CreateCriteria<PersonMembership>()
                .CreateCriteria("User", "user")
                .Add(Restrictions.Eq("user.Name", userName).IgnoreCase())
                .List<PersonMembership>();
            return Single(list);
        }
    }
}
